import request from '@/utils/request'

// 用户 - 基本资料
const getUserAPI = () => {
  return request({
    method: 'get',
    url: '/v1_0/user'
  })
}

// 用户 - 个人资料
const getUserProfileAPI = () => {
  return request({
    method: 'get',
    url: '/v1_0/user/profile'
  })
}

// 上传图片
const uploadPhotoAPI = ({ formData }) => {
  return request({
    method: 'patch',
    url: '/v1_0/user/photo',
    data: formData
  })
}

// 更新用户资料
const updateUserProfileAPI = ({ name, birthday }) => {
  return request({
    method: 'patch',
    url: '/v1_0/user/profile',
    data: {
      name,
      birthday
    }
  })
}

// 更新token
const updateTokenAPI = () => {
  return request({
    url: '/v1_0/authorizations',
    method: 'PUT'
  })
}

export {
  getUserAPI,
  getUserProfileAPI,
  uploadPhotoAPI,
  updateUserProfileAPI,
  updateTokenAPI
}
